<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="expires" content="Thu,01 Jan 1970 00:00:01 GMT">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-cache">
    <!--<meta http-equiv="Content-Security-Policy" content="default-src 'self';font-src 'self' data: https://fonts.gstatic.com https://fonts.googleapis.com/;style-src 'self' 'unsafe-inline'; media-src *;script-src 'self' http://api.map.baidu.com ;">-->
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <link href="__IMG__/logo.png" rel="shortcut icon" type="image/x-icon">
    <title>花椒-辣椒-香料-调味品-附城--成都味之初农产品有限公司</title>
    <base target="_self">
    <meta name="keywords" content="成都调味品批发交易贸易，花椒，辣椒，香料，成都调味品">
    <meta name="description" content="成都味之初农产品有限公司,专注于花椒，辣椒，香料等调味品批发贸易">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link rel="stylesheet" href="__LIB__/layui/css/layui.css">
    <link rel="stylesheet" href="__CSS__/bootstrap.min.css">
    <link rel="stylesheet" href="__CSS__/reset.css">
    <link rel="stylesheet" href="__CSS__/common.css">
    <link rel="stylesheet" href="__CSS__/log-reg.css">
    <script>
        var _hmt = _hmt || [];
        (function() {
            var hm = document.createElement("script");
            hm.src = "https://hm.baidu.com/hm.js?68cca1e88d91513304d45edd3b72a6ba";
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(hm, s);
        })();
    </script>
</head>
<body>
   <div class="fucheng">
        <div class="fucheng-cont">
            <a href="http://cdweizhichu.com/">
                <img src="__IMG__/logo.png" alt="">
                <span>附城</span>
            </a>
        </div>
   </div>
   <div class="form-part">
       <div class="title">注册新用户</div>

       <div class="form-row">
           <img src="__IMG__/user.png" alt="">
           <span class="cn-number">+86</span>
           <input type="text" placeholder="手机号" name="phone" id="phone">

           <span class="tips"></span>
       </div>
       <div class="form-row">
           <img src="__IMG__/captcha.png" alt="">
           <input type="text" placeholder="验证码" name="phone" id="txtCaptcha" maxlength="4">
           <img src="/index/Sms/checkVerify" alt="" id="txtPic">

           <span class="tips"></span>
       </div>
       <div class="form-row">
           <img src="__IMG__/captcha.png" alt="">
           <input type="text" placeholder="验证码" name="phone" id="captcha">
           <button class="get-captcha">获取验证码</button>

           <span class="tips"></span>
       </div>
       <div class="form-row">
           <img src="__IMG__/lock.png" alt="">
           <input type="password" placeholder="密码" name="pwd" id="pwd" minlength="6" maxlength="10">

           <span class="tips"></span>
       </div>
       <div class="form-row">
           <img src="__IMG__/lock.png" alt="">
           <input type="password" placeholder="确认密码" name="repwd" id="repwd">

           <span class="tips"></span>
       </div>

       <div class="bot-info">
           <div class="btn-reg">注册</div>
           <div class="btn-log"><a href="./login.html">已有账号 立即登录</a></div>
       </div>
   </div>
</body>
<script src="__JS__/jQuery-1.11.1.min.js"></script>
<script src="__LIB__/layui/layui.js"></script>
<script src="__JS__/bootstrap.min.js"></script>
<script>
    (function(){
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        }
        else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>
<script>
    $(function () {
        layui.use('layer',function () {
            var layer = layui.layer
        })
        $('.form-row input').on('focus',function () {
            $(this).parent().css({borderColor: '#F6BB6D'})
        }).on('blur',function () {
            $(this).parent().css({borderColor: '#E3E7ED'})
        })

        /*手机验证*/
        var telCheck = /^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$/

        $('#phone').on('blur',function () {
            if(!$(this).val()) {
                $(this).siblings('.tips').html('请填写手机号')
            }else if($(this).val() && !telCheck.test($(this).val())) {
                $(this).siblings('.tips').html('请正确填写手机号')
            }else {
                $(this).siblings('.tips').html('')
            }
        })

        /*获取数字验证码图片*/
        $('#txtPic').on('click',function () {
            var nowTime = new Date().getTime()
            $(this)[0].src = '/index/Sms/checkVerify?time='+nowTime
        })


        /*获取验证码*/
        var codeStatus = true
        $('.get-captcha').on('click',function () {
            if(!codeStatus) {
                return
            }

            var time = 60
            if(!$('#phone').val()) {
                $('#phone').siblings('.tips').html('请填写手机号')
                return
            }
            if(!telCheck.test($('#phone').val())) {
                return
            }
            if(!$('#txtCaptcha').val()) {
                $('#txtCaptcha').siblings('.tips').html('请输入图形验证码')
                return
            }else {
                $('#txtCaptcha').siblings('.tips').html('')
            }


            $.post('/index/Sms/index',{phone: $('#phone').val(),code:$('#txtCaptcha').val()},function (res) {
                if(res.code === 1) {
                    $('#txtCaptcha').siblings('.tips').html('')
                    codeStatus = false
                    var t = setInterval(function () {
                        time--
                        $('.get-captcha').html(time+'s')
                        if(time === 0) {
                            clearInterval(t)
                            $('.get-captcha').html('重新获取')
                            codeStatus = true
                        }
                    },1000)
                }else {
                    $('#txtCaptcha').siblings('.tips').html('图形验证码错误')
                }
            },'json')
        })

        /*验证码*/
        $('#captcha').on('blur',function () {
            if(!$(this).val()) {
                $(this).siblings('.tips').html('请输入验证码')
            }else {
                $(this).siblings('.tips').html('')
            }
        })

        /*输入密码*/
        var pwd_letter = /^[a-zA-Z]{6,20}$/;  //弱，全字母
        var pwd_num = /^[0-9]{6,20}$/;  //弱，全数字
        var pwd_char = /^((?=[\x21-\x7e]+)[^A-Za-z0-9]){6,20}$/;  //弱，全字符
        $('#pwd').on('focus',function () {
            if(!$(this).val()) {
                $(this).siblings('.tips').html('请输入6-20位密码')
            }
        }).on('blur',function () {
            if($(this).val().length < 6) $(this).siblings('.tips').html('请输入6-20位密码')
            else if(pwd_letter.test($(this).val())) $(this).siblings('.tips').html('不能为全字母')
            else if(pwd_num.test($(this).val())) $(this).siblings('.tips').html('不能为全数字')
            else if(pwd_char.test($(this).val())) $(this).siblings('.tips').html('不能为全字符')
            else $(this).siblings('.tips').html('')
        })

        /*重复密码*/
        $('#repwd').on('blur',function () {
            if($(this).val() !== $('#pwd').val()) {
                $(this).siblings('.tips').html('密码不一致')
            }else {
                $(this).siblings('.tips').html('')
            }
        })

        /*注册提交*/
        $('.btn-reg').on('click',function () {
            var errCount = 0
            for(var i=0;i<$('.tips').length;i++) {
                if($('.tips').eq(i).html()) {
                    errCount++
                }
            }
            if(errCount) {
                return
            }
            $.post('/index/Login/memberAdd',{
                memb_phone :$('#phone').val(),
                memb_password : $('#pwd').val(),
                memb_pwd: $('#repwd').val(),
                memb_code: $('#captcha').val(),
            },function (res) {
                if(res.code == 1) {
                    layer.msg('注册成功！',{icon: 1,time: 2000})
                    setTimeout(function(){
                        window.location.href = '/index/index/index.html'
                    }, 3000)
                }else {
                    if(res.msg == '该手机号已注册') {
                        alert('亲，您已注册过了哦!')
                    }
                }
            },'json')
        })
    })

</script>

</html>